
export default function jsonp(url,params,fn){
    var cbName = `jsonp_${(Math.random().toString().substr(2))}`;
    var queryStr = '';
    for(var k in params){
        queryStr+=`${k}=${params[k]}&`
    }
    queryStr+=`callback=${cbName}`;
    url = `${url}?${queryStr}`
    var scriptElement = document.createElement('script');
    scriptElement.src = url;
    window.document.body.appendChild(scriptElement);
    window[cbName] = function(data){
        fn(data);
        document.body.removeChild(scriptElement);
    }
}